#ifndef MOCK_LIGHTTRANSITIONENGINE_H
#define MOCK_LIGHTTRANSITIONENGINE_H

#include "IF_lighttransitionengine.h"

/** @file mock_lighttransitionengine.h
 *
 *This is a mock implementation of class ::LightTransitionEngine.
 *Intead of executing a real transition, in a given time, and actuate
 *it to the DMX interface, it simply stores the request of changes
 */

class MockLightTransitionEngine : public IF_LightTransitionEngine
{
   Q_OBJECT
public:
   explicit MockLightTransitionEngine(QObject *parent = 0) :
      IF_LightTransitionEngine(parent),
      m_lastRequestedValues(NULL),
      m_lastFadeTime(0)
   {
      /* init with fake values to have some valid position */
      m_currentValues << 0. << 0. << 0.;
   }

   /** implementation of pure virtual function */
   virtual void startTransition( const QList<double> &finalValues, int fadeTimeMs)
   {
      m_lastRequestedValues = &finalValues;
      m_lastFadeTime = fadeTimeMs;
   }

   /**
    * implementation of pure virtual function
    * @throw exception(QString()) if channel is over internal data
    */
   virtual void setLevelForChannel( double level, int channel)
   {
      /* just store the values that can be read later */
      if (channel < m_currentValues.length())
      {
         m_currentValues[channel] = level;
      }
      else
      {
         throw QString("invalid channel");
      }
   }

   /**
    * getter for internal variable
    * @throw exception(QString()) if channel is over internal data
    */
   double spyLevelAtChannel(int channel)
   {
      if (channel >= m_currentValues.length())
      {
         throw QString("invalid channel");
      }

      return m_currentValues.at(channel);
   }

   /**
    * @brief simulate that tick time has elapsed. New values for channels
    *    must be emitted
    */
   void simulateTick()
   {
      /* for now emit final values ... */
      emit fadeStep( *m_lastRequestedValues);
   }

   /* spy functions */
   const QList<double> *lastRequestedValues()
   {
      return m_lastRequestedValues;
   }
   int lastFadeTime()
   {
      return m_lastFadeTime;
   }

private:
   QList<double> m_currentValues;
   const QList<double> *m_lastRequestedValues;
   int m_lastFadeTime;
};

#endif // MOCK_LIGHTTRANSITIONENGINE_H
